package guiElements;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.border.BevelBorder;

public class MultiColorSelector extends JPanel {
	
	private MultiColorButton multiColorButton;
	private String colorName;
	private JCheckBox colorCheckBox;
	
	/**
	 * Create the panel.
	 */
	public MultiColorSelector(String colorName){
		this.colorName = colorName;
		this.setLayout(null);
		this.setSize(new Dimension(150,50));
		this.setBackground(Color.white);
		multiColorButton = new MultiColorButton();
		multiColorButton.setBorder(new BevelBorder(BevelBorder.RAISED, Color.gray, Color.black));
		multiColorButton.setSize(new Dimension(25,25));
		multiColorButton.addActionListener(new MultiColorButtonListener());
		this.add(multiColorButton);
		colorCheckBox = new JCheckBox(colorName);
		colorCheckBox.setFont(new Font("Georgia",Font.PLAIN, 16));
		colorCheckBox.setBackground(Color.white);
		colorCheckBox.setLocation(new Point(25,0));
		colorCheckBox.setSize(new Dimension(175,40));
		this.add(colorCheckBox);		
	}
	
	public String colorSelected(){
		if (colorCheckBox.isSelected()){
			return colorName;
		} 
		else {
			return null;
		}
		
	}	
	
	public String getColorName() {
		return colorName;
	}

	public void setColorName(String colorName) {
		this.colorName = colorName;
	}

	public JCheckBox getColorCheckBox() {
		return colorCheckBox;
	}

	public void setColorCheckBox(JCheckBox colorCheckBox) {
		this.colorCheckBox = colorCheckBox;
	}
	
	private class MultiColorButtonListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource()==multiColorButton){
				if(colorCheckBox.isSelected()){
					colorCheckBox.setSelected(false);
				} else colorCheckBox.setSelected(true);
			}
		}
	}
}
